﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.GatherArmyLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class GatherArmyLogEntry : LogEntry, IChatNotification
  {
    [SaveableField(220)]
    public readonly Hero ArmyLeader;
    [SaveableField(221)]
    public readonly IFaction ArmyMapFaction;
    [SaveableField(222)]
    public readonly Settlement GatheringSettlement;

    internal static void AutoGeneratedStaticCollectObjectsGatherArmyLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.ArmyLeader);
      collectedObjects.Add((object) this.ArmyMapFaction);
      collectedObjects.Add((object) this.GatheringSettlement);
    }

    internal static object AutoGeneratedGetMemberValueArmyLeader(object o)
    {
      return (object) ((GatherArmyLogEntry) o).ArmyLeader;
    }

    internal static object AutoGeneratedGetMemberValueArmyMapFaction(object o)
    {
      return (object) ((GatherArmyLogEntry) o).ArmyMapFaction;
    }

    internal static object AutoGeneratedGetMemberValueGatheringSettlement(object o)
    {
      return (object) ((GatherArmyLogEntry) o).GatheringSettlement;
    }

    public override ChatNotificationType NotificationType
    {
      get => this.MilitaryNotification((IFaction) this.ArmyLeader.Clan, (IFaction) null);
    }

    public bool IsVisibleNotification => this.ArmyMapFaction == Hero.MainHero.MapFaction;

    public GatherArmyLogEntry(Army army, Settlement gatheringSettlement)
    {
      this.ArmyLeader = army.LeaderParty.LeaderHero;
      this.ArmyMapFaction = (IFaction) army.Kingdom;
      this.GatheringSettlement = gatheringSettlement;
    }

    public override string ToString() => this.GetNotificationText().ToString();

    public TextObject GetNotificationText()
    {
      TextObject parent = new TextObject("{=Vi5Ylvr1}{LORD.NAME} is gathering army near {SETTLEMENT}");
      StringHelpers.SetCharacterProperties("LORD", this.ArmyLeader.CharacterObject, parent);
      parent.SetTextVariable("SETTLEMENT", this.GatheringSettlement.ToString());
      return parent;
    }
  }
}
